package com.bw.kf.mvvm.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider

abstract class BaseFragment<VDB :ViewDataBinding,VM:BaseRepo>:Fragment(){
    lateinit var binding:VDB
    lateinit var viewModel:VM
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding=DataBindingUtil.inflate(inflater,Layoutid(),container,false)
        viewModel=ViewModelProvider(this)[getViewModel()]
        iniView()
        iniData()
        return binding.root
    }
    abstract fun iniView()
    abstract fun iniData()
    abstract fun getViewModel(): Class<VM>
    abstract fun Layoutid(): Int
}